package com.dmgis.hndz.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dmgis.hndz.pojo.SysConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
@DS("service")
public interface SysConfigMapper extends BaseMapper<SysConfig> {
    /**
     * 查询监控模板
     * @param paramName
     * @return
     */
    @Select("select paramvalue from sys_config where ParamType = '数据监控' AND ParamName = #{paramName}")
    List<String> selectMonitorTemplates(String paramName);

    /**
     * 查询模板
     * @param paramName
     * @return
     */
    @Select("select paramvalue from sys_config where ParamName like '${paramName}%'")
    List<String> searchTemplates(String paramName);

    /**
     * 根据名字和类型修改参数赋值
     * @param paramvalue
     * @param paramname
     * @param paramtype
     * @return
     */
    @Update("UPDATE sys_config  " +
            "SET paramvalue = #{paramvalue} " +
            "WHERE paramname = #{paramname} " +
            "AND paramtype = #{paramtype} ")
    int updateByNameAndTypeOfSysConfig(@Param("paramvalue") String paramvalue, @Param("paramname") String paramname, @Param("paramtype") String paramtype);



}
